#ifndef PLATFORMJUMPSCENE_H
#define PLATFORMJUMPSCENE_H

#include "../Scene/Scene.h"
#include "../GameObject/GameWorld.h"
#include "../InputHandler/input.h"
#include "../Camera/Camera.h"
#include "../Audio/GameAudioManager.h"
#include "../Renderer/BackgroundRenderer.h"
#include "../Renderer/TextureRenderer.h"
#include <memory>

class PlayerController : public Component {
public:
    PlayerController(GameObject* gameObject, InputHandler* inputHandler);

    void update(float deltaTime) override;

    void setMoveSpeed(float speed) { moveSpeed_ = speed; }
    void setJumpForce(float force) { jumpForce_ = force; }

private:
    InputHandler* inputHandler_;
    float moveSpeed_;
    float jumpForce_;
    Rigidbody* rigidbody_;
};

class PlatformJumpScene : public GameEngine::Scene {
public:
    PlatformJumpScene(const std::string& name);
    ~PlatformJumpScene() override;

    void OnCreate() override;
    void OnDestroy() override;
    void OnActivate() override;
    void OnDeactivate() override;
    void Update(float deltaTime) override;
    void Render() override;

private:
    std::unique_ptr<GameWorld> gameWorld_;
    std::unique_ptr<InputHandler> inputHandler_;
    std::unique_ptr<Camera> camera_;
    std::unique_ptr<BackgroundRenderer> backgroundRenderer_; // Background renderer

    GameObject* player_;
    std::vector<GameObject*> platforms_;

    // Game state
    int score_;
    float gameTime_;
    float gameTimeLimit_;
    bool gameEnded_;
    std::vector<bool> platformScored_;    void createPlayer();
    void createPlatforms();
    void setupBackground();
    void loadTextures(); // Add texture loading method
    void checkCollisions();
    void performContinuousCollisionCheck();
    void updateCamera();void setupCamera();
    void updateGameState(float deltaTime);
    void checkPlatformScoring();
    void renderUI();
    void endGame(bool won);
    void resetGame(); // Add reset method

    // World bounds for camera
    static const float WORLD_WIDTH;
    static const float WORLD_HEIGHT;
};

#endif // PLATFORMJUMPSCENE_H
